package conf2.model;

import conf2.model.EActor.Side;
import java.util.Comparator;
import static conf2.model.EActor.Side.*;

public enum ECard
{

    L_1(1, LIGHT, "1", "Add 1 to your strength rating.", 1),
    L_2(2, LIGHT, "2", "Add 2 to your strength rating.", 2),
    L_3(3, LIGHT, "3", "Add 3 to your strength rating.", 3),
    L_4(4, LIGHT, "4", "Add 4 to your strength rating.", 4),
    L_5(5, LIGHT, "5", "Add 5 to your strength rating.", 5),
    L_ELVEN(0, LIGHT, "Elven Cloak", "Ignore strength value of opponent's card.", 6),
    L_MAGIC(0, LIGHT, "Magic", "Immediately replace this card with a previouly played card.", 9),
    L_NOBLE(0, LIGHT, "Noble Sacrifice", "Both characters are instantly defeated.", 7),
    L_RETREAT(0, LIGHT, "Retreat", "Immediately retreat backwards.", 8),
    D_1(1, DARK, "1", "Add 1 to your strength rating.", 1),
    D_2(2, DARK, "2", "Add 2 to your strength rating.", 2),
    D_3(3, DARK, "3", "Add 3 to your strength rating.", 3),
    D_4(4, DARK, "4", "Add 4 to your strength rating.", 4),
    D_5(5, DARK, "5", "Add 5 to your strength rating.", 5),
    D_6(6, DARK, "6", "Add 6 to your strength rating.", 6),
    D_EYE_OF_SAURON(0, DARK, "Eye of Sauron", "Ignore opponent's text card.", 7),
    D_RETREAT(0, DARK, "Retreat", "Immediately retreat sideways.", 8),
    D_MAGIC(0, DARK, "Magic", "Immediately replace this card with a previously played card.", 9);
    public static final ECard[] LIGHT_CARDS = {
        L_1, L_2, L_3, L_4, L_5, L_ELVEN, L_MAGIC, L_NOBLE, L_RETREAT
    };
    public static final ECard[] DARK_CARDS = {
        D_1, D_2, D_3, D_4, D_5, D_6, D_EYE_OF_SAURON, D_RETREAT, D_MAGIC
    };

    private static final class CardComparator implements
            Comparator<ECard>
    {

        public int compare(ECard o1, ECard o2)
        {
            return o1.sortIndex - o2.sortIndex;
        }
    }
    private static final CardComparator comparator = new CardComparator();
    private final int attackBonus;
    private final EActor.Side side;
    private final String name;
    private final String description;
    private final int sortIndex;

    private ECard(int attackBonus, Side side, String name, String description, int sortIndex)
    {
        this.attackBonus = attackBonus;
        this.side = side;
        this.name = name;
        this.description = description;
        this.sortIndex = sortIndex;
    }

    public int getAttackBonus()
    {
        return attackBonus;
    }

    public boolean isDark()
    {
        return side == DARK;
    }

    public boolean isLight()
    {
        return side == LIGHT;
    }

    public Side getSide()
    {
        return side;
    }

    public String getCardName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    public static Comparator<ECard> getComparator()
    {
        return comparator;
    }

}
